home *** CD-ROM | disk | FTP | other *** search
/ Knitting Made Easy / Knitting.iso / App / Patterns.dxr / behaviors_192_Scroll Indicator Behavior2.ls < prev    next >
Encoding:
Text File  |  2002-04-18  |  2.1 KB  |  70 lines

  1. property pIndicatorLowerLimit, pIndicatorRange, pClickedStatus, pCurrentSprite
  2. global trackRatio
  3.  
  4. on beginSprite me
  5.   pCurrentSprite = me.spriteNum
  6.   spacing = 3
  7.   offset = (the height of sprite pCurrentSprite / 2) + spacing
  8.   trackSprite = pCurrentSprite - 1
  9.   trackSpriteTop = the top of sprite trackSprite
  10.   pIndicatorLowerLimit = trackSpriteTop + offset
  11.   trackSpriteBottom = the bottom of sprite trackSprite
  12.   indicatorUpperLimit = trackSpriteBottom - offset
  13.   pIndicatorRange = indicatorUpperLimit - pIndicatorLowerLimit
  14.   set the locV of sprite pCurrentSprite to pIndicatorLowerLimit
  15. end
  16.  
  17. on positionIndicator me, textRatio
  18.   currentPosition = pIndicatorRange * textRatio
  19.   indicatorPosition = currentPosition + pIndicatorLowerLimit
  20.   set the locV of sprite pCurrentSprite to indicatorPosition
  21. end
  22.  
  23. on mouseDown me
  24. end
  25.  
  26. on exitFrame me
  27.   if the mouseDown and (the clickOn = pCurrentSprite) then
  28.     scrollTextWithIndicator(me, the mouseV)
  29.     trackRatio = the locV of sprite pCurrentSprite
  30.   end if
  31.   if the mouseDown then
  32.     trackRatio = the locV of sprite pCurrentSprite
  33.   end if
  34.   scrollTextWithIndicator(me, trackRatio)
  35. end
  36.  
  37. on scrollTextWithIndicator me, mouseVertical
  38.   nextPosition = mouseVertical
  39.   if nextPosition < pIndicatorLowerLimit then
  40.     nextPosition = pIndicatorLowerLimit
  41.   else
  42.     upperLimit = pIndicatorLowerLimit + pIndicatorRange
  43.     if nextPosition > upperLimit then
  44.       nextPosition = upperLimit
  45.     end if
  46.   end if
  47.   ratioPosition = float(nextPosition - pIndicatorLowerLimit)
  48.   ratio = ratioPosition / pIndicatorRange
  49.   sendAllSprites(#scrollText, ratio)
  50. end
  51.  
  52. on startitright me, mouseVertical
  53.   nextPosition = mouseVertical
  54.   if nextPosition < pIndicatorLowerLimit then
  55.     nextPosition = pIndicatorLowerLimit
  56.   else
  57.     upperLimit = pIndicatorLowerLimit + pIndicatorRange
  58.     if nextPosition > upperLimit then
  59.       nextPosition = upperLimit
  60.     end if
  61.   end if
  62.   ratioPosition = float(nextPosition - pIndicatorLowerLimit)
  63.   ratio = ratioPosition / pIndicatorRange
  64.   sendAllSprites(#scrollText, ratio)
  65. end
  66.  
  67. on getIndicatorPosition me
  68.   return the locV of sprite pCurrentSprite
  69. end
  70.